package models

import "gorm.io/gorm"

type Goods struct {
	gorm.Model
	UserId int     `type:"int;not null;commit:'用户Id'"`
	Title  string  `type:"varchar(100);not null;commit:'商品标题'"`
	Image  string  `type:"varchar(100);not null;commit:'商品图片'"`
	Price  float64 `type:"decimal(10,2);not null;commit:'商品价格'"`
	Stock  int64   `type:"int;not null;commit:'商品库存'"`
	Status int64   `type:"int;default:1;not null;commit:'商品上下架: 1-上架,2-下架'"`
}

func (g *Goods) GoodAdd() error {
	return DB.Debug().Create(&g).Error
}
func (g *Goods) GoodList() error {
	return DB.Where("id=?", g.ID).Limit(1).Find(&g).Error
}
